<template>
  <div class="app-container">
    <uc-table url="admin/maintenanceRecord/getInRecordsPage" ref="followUserTable" name="维保工单" table-border pageable :search-form="searchForm">
      <template slot="searchForm">
        <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">

        </el-form>
      </template>
      <template slot="columns">
        <el-table-column prop="userName" label="维保人员" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="enterpriseName" label="业主企业" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="equipmentName" label="设备名称" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="maintenaceEnterpriseName" label="维保企业" align="left" :show-overflow-tooltip="true"></el-table-column>
<!--        <el-table-column prop="equipmentStatus" label="设备状态" align="left" :show-overflow-tooltip="true">-->
<!--          <template slot-scope="scope">-->
<!--            {{scope.row.equipmentStatus | maintenanceEquipmentStatus}}-->
<!--          </template>-->
<!--        </el-table-column>-->
          <el-table-column prop="addTime" label="记录时间" align="left" :show-overflow-tooltip="true">
              <template slot-scope="scope">
                  {{scope.row.addTime | dateFormat}}
              </template>
          </el-table-column>
        <el-table-column prop="address" label="操作" width="180" align="left" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <!--编辑按钮-->
            <el-button size="mini" icon="el-icon-info" type="success" @click="handleInfo(scope.row)">详情</el-button>
            <el-button size="mini" type="danger" icon="el-icon-delete" :loading="deleteLoading" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </template>
    </uc-table>
  </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {removeRecords} from "../../../api/maintenanceRecord";


export default {

  name: "list",
  components: {UcTable},
  data(){
    return{
      searchForm:{},
      deleteLoading:false,
    }
  },
  methods: {
    handleSearch() {
      this.$refs.followUserTable.getTableData(1)
    },
    handleAdd() {
      this.$router.push("/maintenance/recordsEdit")
    },
    handleEdit(val) {
      this.$router.push("/maintenance/recordsEdit?ucId=" + val.ucId)
    },
    handleInfo(val) {
      this.$router.push("/maintenance/recordsInfo?ucId=" + val.ucId)
    },
    handleDelete(val) {
      this.$confirm('您确定要执行删除' + val.name + '这条维保记录吗？', '提醒信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteLoading = true
        removeRecords(val).then(res => {
          this.deleteLoading = false
          this.$notify.success({
            title: '成功',
            message: "删除维保记录成功"
          })
          this.handleSearch()
        }).catch(res => {
          this.deleteLoading = false
          this.$notify.error({
            title: '失败',
            message: res.msg
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
  }
}
</script>

<style
    scoped>

</style>